package com.gitee.zycra.union.api.service;

import com.gitee.zycra.union.api.common.bo.CommonResult;
import com.gitee.zycra.union.api.common.param.AddInterfaceCaseParam;
import com.gitee.zycra.union.api.common.param.UpdateInterfaceCaseParam;
import com.gitee.zycra.union.api.common.vo.InterfaceCaseVO;
import com.gitee.zycra.union.api.manager.ApiInterfaceCaseManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zycra
 */
@Slf4j
@Service
public class ApiInterfaceCaseService {

    @Autowired
    private ApiInterfaceCaseManager apiInterfaceCaseManager;

    /**
     * 添加接口
     *
     * @param addInterfaceCaseParam 添加参数
     * @return 添加结果
     */
    public CommonResult<String> addInterfaceCase(AddInterfaceCaseParam addInterfaceCaseParam) {
        apiInterfaceCaseManager.addInterfaceCase(addInterfaceCaseParam);
        return CommonResult.success();
    }

    /**
     * 更新接口期望
     *
     * @param updateInterfaceCaseParam 更新参数
     * @return 更新结果
     */
    public CommonResult<String> updateInterfaceCase(UpdateInterfaceCaseParam updateInterfaceCaseParam) {
        apiInterfaceCaseManager.updateInterfaceCase(updateInterfaceCaseParam);
        return CommonResult.success();
    }

    /**
     * 删除接口期望
     *
     * @param id 接口期望ID
     * @return 删除结果
     */
    public CommonResult<String> deleteInterfaceCase(Long id) {
        apiInterfaceCaseManager.deleteInterfaceCase(id);
        return CommonResult.success();
    }

    /**
     * 查询接口期望
     *
     * @param interfaceId 接口ID
     * @return 查询结果
     */
    public CommonResult<List<InterfaceCaseVO>> selectByInterfaceId(Long interfaceId) {
        return CommonResult.success(apiInterfaceCaseManager.selectByInterfaceId(interfaceId));
    }
}
